<script setup lang="ts">
	import { onMounted, ref } from 'vue'
	import { postSpecialRequests } from '@/api/Hotel'
	// import type { AddressItem } from '../../../types/index'
	// const List = ref<any[]>([])
	// const getInitData = async () => {
	// 	let res = await postSpecialRequests()
	// 	List.value = res.data
	// 	console.log(res)
	// }
	
	defineProps<{
		List:{name:string,id:number,isSelected:boolean}[]
	}>()
	const select = (list:any) => {
		const arr=list.filter(item => item.isSelected).map(item => item.id);
		console.log(arr)
		emit('select',arr)
	}
	const emit = defineEmits(['select'])


	// onMounted(() => {
	// 	getInitData()
	// })
</script>

<template>
	<view class="address-panel">
		<text class="close icon-close" @click="select(List)">确认</text>
		<view class="title">特殊要求</view>
		<view class="content">
			<view class="item" v-for="item in List" :key="item.id" @click="item.isSelected= !item.isSelected;">
				<view class="address">{{item.name}}</view>
				<text :class="item.isSelected?'icon icon-2xuanzhong':'icon icon-yuanquan'"></text>
			</view>
		</view>
	</view>
</template>

<style lang="scss">
	.address-panel {
		padding: 0 30rpx;
		border-radius: 10rpx 10rpx 0 0;
		position: relative;
		background-color: #fff;
	}

	.title {
		line-height: 1;
		padding: 40rpx 0;
		text-align: center;
		font-size: 32rpx;
		font-weight: normal;
		border-bottom: 1rpx solid #ddd;
		color: #444;
	}

	.close {
		position: absolute;
		right: 24rpx;
		top: 24rpx;
	}

	.content {
		min-height: 300rpx;
		max-height: 540rpx;
		overflow: auto;
		padding: 20rpx;

		.item {
			padding: 30rpx 50rpx 30rpx 60rpx;
			background-size: 40rpx;
			background-repeat: no-repeat;
			background-position: 0 center;
			// background-image: url(https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/images/locate.png);
			position: relative;
		}

		.icon {
			color: #999;
			font-size: 40rpx;
			transform: translateY(-50%);
			position: absolute;
			top: 50%;
			right: 0;
		}

		.icon-checked {
			color: $uni-color-primary;
		}

		.icon-ring {
			color: #444;
		}

		.user {
			font-size: 28rpx;
			color: #444;
			font-weight: 500;
		}

		.address {
			font-size: 26rpx;
			color: #666;
		}
	}

	.footer {
		display: flex;
		justify-content: space-between;
		padding: 20rpx 0 40rpx;
		font-size: 28rpx;
		color: #444;

		.button {
			flex: 1;
			height: 72rpx;
			text-align: center;
			line-height: 72rpx;
			margin: 0 20rpx;
			color: #fff;
			border-radius: 72rpx;
		}

		.primary {
			color: #fff;
			background-color: $uni-color-primary;
		}

		.secondary {
			background-color: #ffa868;
		}
	}
</style>